Skip to content

fix: correct Copilot extension command registration#1724

Open
ismaelJimenez wants to merge 2 commits intogithub:mainfrom
ismaelJimenez:fix/copilot-extension-registration
Open

fix: correct Copilot extension command registration#1724
ismaelJimenez wants to merge 2 commits intogithub:mainfrom
ismaelJimenez:fix/copilot-extension-registration

Conversation

@ismaelJimenez
Copy link

  • Use .agent.md extension for commands in .github/agents/
  • Generate companion .prompt.md files in .github/prompts/
  • Clean up .prompt.md files on extension removal
  • Add tests for Copilot-specific registration behavior

Bumps version to 0.1.7.

Description

The specify extension add --dev command didn't work correctly for GitHub Copilot projects. Three issues were identified and fixed:

  1. Wrong file extension: Commands were written as .md instead of .agent.md in .github/agents/, so Copilot couldn't discover them as agent files.
  2. Missing companion prompts: Copilot requires a matching .prompt.md file in .github/prompts/ for each agent — these were never generated.
  3. Incomplete cleanup: On specify extension remove, the .prompt.md companion files were not deleted.

The root cause was a mismatch between CommandRegistrar.AGENT_CONFIGS (used by the CLI) and the release packaging script (create-release-packages.sh), which correctly handled all three cases.

Testing

  • Ran existing tests with uv sync && uv run pytest
  • Tested locally with uv run specify --help
  • Tested with a sample project (if applicable)

107 tests pass. New tests added:

  • test_register_commands_for_copilot — verifies .agent.md extension is used
  • test_copilot_companion_prompt_created — verifies .prompt.md generation
  • test_copilot_aliases_get_companion_prompts — verifies aliases also get prompts
  • test_non_copilot_agent_no_companion_file — verifies no prompts for other agents
  • test_copilot_cleanup_removes_prompt_files — verifies cleanup of prompt files

AI Disclosure

  • I did use AI assistance (describe below)

GitHub Copilot (Claude Opus 4.6) was used to investigate the bug, implement the fix, and write the tests. All changes were reviewed and validated by a human.

- Use .agent.md extension for commands in .github/agents/
- Generate companion .prompt.md files in .github/prompts/
- Clean up .prompt.md files on extension removal
- Add tests for Copilot-specific registration behavior

Bumps version to 0.1.7.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes three bugs in the specify extension add --dev flow for GitHub Copilot projects: the wrong file extension was used for agent commands (.md instead of .agent.md), companion .prompt.md files in .github/prompts/ were never generated, and those companion files were not deleted on extension removal. The fixes bring the CLI's CommandRegistrar in line with the existing create-release-packages.sh script, which already handled all three cases correctly.

Changes:

  • CommandRegistrar.AGENT_CONFIGS["copilot"]["extension"] corrected to .agent.md; new _write_copilot_prompt() static helper generates companion .prompt.md files during registration; remove() now also deletes companion .prompt.md files for Copilot
  • Five new unit tests covering the Copilot-specific registration and cleanup behavior
  • Version bumped to 0.1.7 and CHANGELOG updated

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/specify_cli/extensions.py Core fix: corrects .agent.md extension, adds _write_copilot_prompt(), adds prompt-file cleanup in remove()
tests/test_extensions.py Five new tests for Copilot registration and cleanup behavior
pyproject.toml Version bump 0.1.60.1.7
CHANGELOG.md Adds [0.1.7] entry describing the three fixes

The production code changes in extensions.py are correct and well-structured. However, there is one critical issue with the test suite:

The new test_copilot_cleanup_removes_prompt_files test does not actually call ExtensionManager.remove(). It manually unlinks the files with Path.unlink(), so the new cleanup logic introduced in remove() (lines 458–462 of extensions.py) is never exercised by any test. If that code contained a bug (e.g., wrong path, wrong condition), this test would still pass.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@mnriem mnriem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you pull in the latest changes from main?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants